#ifndef __PCR_H__
#define __PCR_H__

#if defined(USE_HAL_DRIVER)
  #if defined(STM32F405xx) || defined(STM32F407xx) || defined(STM32F429xx)
    #include <stm32f4xx_hal.h>
  #endif
  #if defined(STM32F103xx)
    #include <stm32f1xx_hal.h>
  #endif
  #if defined(STM32H750xx)
    #include <stm32h7xx_hal.h>
  #endif
#endif
#include <FreeRTOS.h>
#include <queue.h>
#include <SRML.h>

#ifdef __cplusplus
class PCR{
public:
    PCR(){};
	void init(uint8_t index, QueueHandle_t CAN_TX, QueueHandle_t CAN_RX);
	void start(float* temp, uint16_t* time);
	void updateData(CAN_COB msg);
	void heartBeat(void);
	void setTemp(float *temp, uint8_t cycles, uint8_t mode, uint8_t stage_num, uint8_t stage);
	void setTime(uint16_t *time, uint8_t* gather);
	void start(bool en, uint8_t channel);
  void enableHeat(bool en);
        
	// state    
	uint8_t state_flag[2];
	float temp[2];
	float coreTemp;
	uint8_t heat_flag;
	void setCircle(uint16_t circle){ target_circle = circle;}
	uint16_t getColorData(uint8_t* buf);
    
private:
	uint16_t circle = 0;
	uint16_t data = 0;
	uint16_t target_circle = 45;
   	bool rev_complete = false; 
    uint8_t checksum(uint8_t *data);
	uint8_t rev_available(uint8_t *data);
	uint8_t data_buf[24];
	uint8_t rx_data[24];
	QueueHandle_t CAN_TX_PORT;
	QueueHandle_t CAN_RX_PORT;
	uint16_t id;
	uint16_t red;
	uint16_t yellow;
	uint16_t green;
	uint16_t blue;

	uint16_t color_data[180];
    uint16_t color_values[180];
    
};

#endif

#endif


